package com.shopping.dao.Impl;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import com.shopping.dao.IBaseDao;
import com.shopping.model.Tops;
@Repository
public interface ITopsDao extends IBaseDao<Tops>{

	@Override
	@Select("select * from tops")
	List<Tops> selectAll();

	@Override
	@Select("select * from tops limit #{m},#{n}")
	List<Tops> selectByPage(@Param("m")Integer offset, @Param("n")Integer rows);
	
	@Select("select * from tops where good_id=#{goodId}")
	Tops selectTopsByGoodId(@Param("goodId")Integer goodId);

	@Select("select * from tops where type=#{typeId}")
	List<Tops> selectTopsByTypeId(@Param("typeId")Integer typeId);
	
	@Select("delete from tops where good_id=#{goodId}")
	Integer deleteByGoodId(@Param("goodId")Integer goodId);
	
	@Override
	@Select("insert into tops values(null,#{type},#{goodId})")
	Integer insert(Tops entity);

	@Override
	@Delete("delete from tops where id=#{id}")
	Integer deleteById(@Param("id")Integer id);

	/**
	 * 没有要求修改推荐功能，故不写
	 */
	@Override
	Integer update(Tops entity);

}
